package com.prs.crm.action.stock.flow;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.ui.PaginationSupport;

import com.prs.crm.action.FlowAction;
import com.prs.crm.annotation.Clew;
import com.prs.crm.context.AppContext;

import com.prs.crm.domain.stock.Purchase;
import com.prs.crm.service.stock.PurchaseService;

public class PurchaseFlowAction extends FlowAction<Purchase> {
	
	private Purchase purchase;
	private PurchaseService purchaseService;	
	private PaginationSupport pagination;
	
	
	@Action("listPurchaseFlow")
	public String listPuechaseFlow() {
		pagination = this.getPaginationHelper().prepare(pagination);
		pagination = this.getPurchaseService().listFlowTask(Purchase.class, pagination, AppContext.getAccountContext().currentUser());
		return SUCCESS;
	}
	
	@Action("editPurchaseFlow")
	public String editPurchaseFlow() {
		this.displayEndNodes();		
		return SUCCESS;
	}
	
	@Clew(results={"success"})
	@Action(value="submitPurchaseFlow",results={@Result(name="success",type="redirect",location="listPurchaseFlow")})
	public String submitPurchaseFlow() {
		this.getPurchaseService().execute(this.getNode(), this.getDetail(), purchase, AppContext.getAccountContext().currentUser());
		this.setPrompt("提交成功");
		return SUCCESS;
	}
	
	
	
	
	public Purchase getPurchase() {
		return purchase;
	}
	public void setPurchase(Purchase purchase) {
		this.purchase = purchase;
	}
	public PurchaseService getPurchaseService() {
		return purchaseService;
	}
	public void setPurchaseService(PurchaseService purchaseService) {
		this.purchaseService = purchaseService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	
	
	

}
